using DataDynamics.ActiveReports;
using DataDynamics.ActiveReports.Export.Xls;
using SS;
using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Windows.Forms;
using TVSBH.func;
namespace TVSGPP.func
{
	public class frmTracePatients : Form
	{
		private IContainer components = null;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.Label label8;
		private DataGridView dgvBill;
		private Button btnClose;
		private Button btnPrint;
		private DataGridViewTextBoxColumn CreateDate;
		private DataGridViewTextBoxColumn _Name;
		private DataGridViewTextBoxColumn DoctorName;
		private DataGridViewTextBoxColumn DoctorDesease;
		private new DataGridViewTextBoxColumn ProductName;
		private DataGridViewTextBoxColumn ProductNumber;
		private DataGridViewTextBoxColumn Column1;
		private Button btnExportToExcel;
		private Button btnSearch;
		private System.Windows.Forms.Label label25;
		private System.Windows.Forms.Label label17;
		private DateTimePicker dtpTo;
		private DateTimePicker dtpFrom;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn6;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn7;
		private Func objFunc = new Func();
		private DataTable objTable = new DataTable();
		private string currWhID = "";
		public string userName = "";
		public string fullName = "";
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			DataGridViewCellStyle dataGridViewCellStyle = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle();
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(frmTracePatients));
			DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle4 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle5 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle6 = new DataGridViewCellStyle();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.label6 = new System.Windows.Forms.Label();
			this.label7 = new System.Windows.Forms.Label();
			this.label8 = new System.Windows.Forms.Label();
			this.dgvBill = new DataGridView();
			this.btnClose = new Button();
			this.btnPrint = new Button();
			this.btnExportToExcel = new Button();
			this.btnSearch = new Button();
			this.label25 = new System.Windows.Forms.Label();
			this.label17 = new System.Windows.Forms.Label();
			this.dtpTo = new DateTimePicker();
			this.dtpFrom = new DateTimePicker();
			this.dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn2 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn3 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn4 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn5 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn6 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn7 = new DataGridViewTextBoxColumn();
			this.CreateDate = new DataGridViewTextBoxColumn();
			this._Name = new DataGridViewTextBoxColumn();
			this.DoctorName = new DataGridViewTextBoxColumn();
			this.DoctorDesease = new DataGridViewTextBoxColumn();
			this.ProductName = new DataGridViewTextBoxColumn();
			this.ProductNumber = new DataGridViewTextBoxColumn();
			this.Column1 = new DataGridViewTextBoxColumn();
			((ISupportInitialize)this.dgvBill).BeginInit();
			base.SuspendLayout();
			this.label1.Font = new Font("Arial", 12f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label1.Location = new Point(8, 9);
			this.label1.Name = "label1";
			this.label1.Size = new Size(882, 30);
			this.label1.TabIndex = 0;
			this.label1.Text = "SỔ THEO DÕI BỆNH NHÂN";
			this.label1.TextAlign = ContentAlignment.MiddleCenter;
			this.label2.BorderStyle = BorderStyle.FixedSingle;
			this.label2.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label2.Location = new Point(6, 46);
			this.label2.Name = "label2";
			this.label2.Size = new Size(91, 45);
			this.label2.TabIndex = 1;
			this.label2.Text = "Ngày";
			this.label2.TextAlign = ContentAlignment.MiddleCenter;
			this.label3.BorderStyle = BorderStyle.FixedSingle;
			this.label3.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label3.Location = new Point(96, 46);
			this.label3.Name = "label3";
			this.label3.Size = new Size(203, 45);
			this.label3.TabIndex = 2;
			this.label3.Text = "Thông tin về bệnh nhân [ Tuổi, địa chỉ ]";
			this.label3.TextAlign = ContentAlignment.MiddleCenter;
			this.label4.BorderStyle = BorderStyle.FixedSingle;
			this.label4.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label4.Location = new Point(296, 46);
			this.label4.Name = "label4";
			this.label4.Size = new Size(204, 45);
			this.label4.TabIndex = 3;
			this.label4.Text = "Họ tên, địa chỉ BS kê đơn";
			this.label4.TextAlign = ContentAlignment.MiddleCenter;
			this.label5.BorderStyle = BorderStyle.FixedSingle;
			this.label5.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label5.Location = new Point(499, 46);
			this.label5.Name = "label5";
			this.label5.Size = new Size(184, 45);
			this.label5.TabIndex = 4;
			this.label5.Text = "Chuẩn đoán của Bác sĩ kê đơn";
			this.label5.TextAlign = ContentAlignment.MiddleCenter;
			this.label6.BorderStyle = BorderStyle.FixedSingle;
			this.label6.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label6.Location = new Point(682, 46);
			this.label6.Name = "label6";
			this.label6.Size = new Size(212, 23);
			this.label6.TabIndex = 5;
			this.label6.Text = "Thuốc bệnh nhân đã mua";
			this.label6.TextAlign = ContentAlignment.MiddleCenter;
			this.label7.BorderStyle = BorderStyle.FixedSingle;
			this.label7.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label7.Location = new Point(682, 68);
			this.label7.Name = "label7";
			this.label7.Size = new Size(166, 23);
			this.label7.TabIndex = 6;
			this.label7.Text = "Tên thuốc";
			this.label7.TextAlign = ContentAlignment.MiddleCenter;
			this.label8.BorderStyle = BorderStyle.FixedSingle;
			this.label8.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label8.Location = new Point(847, 68);
			this.label8.Name = "label8";
			this.label8.Size = new Size(47, 23);
			this.label8.TabIndex = 7;
			this.label8.Text = "SL";
			this.label8.TextAlign = ContentAlignment.MiddleCenter;
			this.dgvBill.AllowUserToAddRows = false;
			this.dgvBill.AllowUserToDeleteRows = false;
			this.dgvBill.AllowUserToResizeColumns = false;
			this.dgvBill.AllowUserToResizeRows = false;
			dataGridViewCellStyle.BackColor = Color.FromArgb(192, 255, 255);
			dataGridViewCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvBill.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle;
			this.dgvBill.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.dgvBill.BackgroundColor = Color.White;
			this.dgvBill.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.dgvBill.ColumnHeadersVisible = false;
			this.dgvBill.Columns.AddRange(new DataGridViewColumn[]
			{
				this.CreateDate,
				this._Name,
				this.DoctorName,
				this.DoctorDesease,
				this.ProductName,
				this.ProductNumber,
				this.Column1
			});
			this.dgvBill.Location = new Point(6, 90);
			this.dgvBill.Name = "dgvBill";
			this.dgvBill.RowHeadersVisible = false;
			dataGridViewCellStyle2.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvBill.RowsDefaultCellStyle = dataGridViewCellStyle2;
			this.dgvBill.RowTemplate.DefaultCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvBill.Size = new Size(888, 470);
			this.dgvBill.TabIndex = 8;
			this.btnClose.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			this.btnClose.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnClose.Location = new Point(803, 565);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new Size(91, 30);
			this.btnClose.TabIndex = 39;
			this.btnClose.Text = "Thoát [ESC]";
			this.btnClose.UseVisualStyleBackColor = true;
			this.btnClose.Click += new EventHandler(this.btnClose_Click);
			this.btnPrint.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnPrint.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnPrint.Location = new Point(6, 565);
			this.btnPrint.Name = "btnPrint";
			this.btnPrint.Size = new Size(105, 30);
			this.btnPrint.TabIndex = 40;
			this.btnPrint.Text = "In báo cáo [ F7 ]";
			this.btnPrint.UseVisualStyleBackColor = true;
			this.btnPrint.Click += new EventHandler(this.btnPrint_Click);
			this.btnExportToExcel.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnExportToExcel.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnExportToExcel.Location = new Point(113, 565);
			this.btnExportToExcel.Name = "btnExportToExcel";
			this.btnExportToExcel.Size = new Size(102, 30);
			this.btnExportToExcel.TabIndex = 46;
			this.btnExportToExcel.Text = "Xuất file Excel";
			this.btnExportToExcel.UseVisualStyleBackColor = true;
			this.btnExportToExcel.Click += new EventHandler(this.btnExportToExcel_Click);
			this.btnSearch.FlatAppearance.BorderSize = 0;
			this.btnSearch.FlatStyle = FlatStyle.Flat;
			this.btnSearch.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
//			this.btnSearch.Image = (Image)componentResourceManager.GetObject("btnSearch.Image");
			this.btnSearch.Location = new Point(262, 12);
			this.btnSearch.Name = "btnSearch";
			this.btnSearch.Size = new Size(30, 22);
			this.btnSearch.TabIndex = 157;
			this.btnSearch.UseVisualStyleBackColor = true;
			this.btnSearch.Click += new EventHandler(this.btnSearch_Click);
			this.label25.AutoSize = true;
			this.label25.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.label25.Location = new Point(9, 16);
			this.label25.Name = "label25";
			this.label25.Size = new Size(57, 15);
			this.label25.TabIndex = 156;
			this.label25.Text = "Từ ngày :";
//			this.label17.Image = (Image)componentResourceManager.GetObject("label17.Image");
			this.label17.Location = new Point(154, 12);
			this.label17.Name = "label17";
			this.label17.Size = new Size(20, 25);
			this.label17.TabIndex = 155;
			this.dtpTo.CustomFormat = "dd/MM/yyyy";
			this.dtpTo.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.dtpTo.Format = DateTimePickerFormat.Custom;
			this.dtpTo.Location = new Point(176, 13);
			this.dtpTo.Name = "dtpTo";
			this.dtpTo.Size = new Size(81, 21);
			this.dtpTo.TabIndex = 154;
			this.dtpFrom.CustomFormat = "dd/MM/yyyy";
			this.dtpFrom.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.dtpFrom.Format = DateTimePickerFormat.Custom;
			this.dtpFrom.Location = new Point(70, 13);
			this.dtpFrom.Name = "dtpFrom";
			this.dtpFrom.Size = new Size(81, 21);
			this.dtpFrom.TabIndex = 153;
			this.dataGridViewTextBoxColumn1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn1.DataPropertyName = "CreateDate";
			dataGridViewCellStyle3.Format = "D";
			dataGridViewCellStyle3.NullValue = null;
			this.dataGridViewTextBoxColumn1.DefaultCellStyle = dataGridViewCellStyle3;
			this.dataGridViewTextBoxColumn1.HeaderText = "Ngày";
			this.dataGridViewTextBoxColumn1.MinimumWidth = 89;
			this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
			this.dataGridViewTextBoxColumn1.Width = 89;
			this.dataGridViewTextBoxColumn2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn2.DataPropertyName = "_Name";
			this.dataGridViewTextBoxColumn2.HeaderText = "Thông tin bệnh nhân";
			this.dataGridViewTextBoxColumn2.MinimumWidth = 200;
			this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
			this.dataGridViewTextBoxColumn2.Width = 200;
			this.dataGridViewTextBoxColumn3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn3.DataPropertyName = "_DoctorName";
			this.dataGridViewTextBoxColumn3.HeaderText = "DoctorName";
			this.dataGridViewTextBoxColumn3.MinimumWidth = 203;
			this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
			this.dataGridViewTextBoxColumn3.Width = 203;
			this.dataGridViewTextBoxColumn4.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn4.DataPropertyName = "_DoctorDesease";
			this.dataGridViewTextBoxColumn4.HeaderText = "DoctorDesease";
			this.dataGridViewTextBoxColumn4.MinimumWidth = 183;
			this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
			this.dataGridViewTextBoxColumn4.Width = 183;
			this.dataGridViewTextBoxColumn5.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn5.DataPropertyName = "ProductName";
			this.dataGridViewTextBoxColumn5.HeaderText = "ProductName";
			this.dataGridViewTextBoxColumn5.MinimumWidth = 165;
			this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
			this.dataGridViewTextBoxColumn5.Width = 165;
			this.dataGridViewTextBoxColumn6.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn6.DataPropertyName = "ProductNumber";
			dataGridViewCellStyle4.Alignment = DataGridViewContentAlignment.MiddleRight;
			this.dataGridViewTextBoxColumn6.DefaultCellStyle = dataGridViewCellStyle4;
			this.dataGridViewTextBoxColumn6.HeaderText = "N";
			this.dataGridViewTextBoxColumn6.MinimumWidth = 46;
			this.dataGridViewTextBoxColumn6.Name = "dataGridViewTextBoxColumn6";
			this.dataGridViewTextBoxColumn6.Width = 46;
			this.dataGridViewTextBoxColumn7.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.dataGridViewTextBoxColumn7.HeaderText = "Column1";
			this.dataGridViewTextBoxColumn7.Name = "dataGridViewTextBoxColumn7";
			this.CreateDate.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.CreateDate.DataPropertyName = "CreateDate";
			dataGridViewCellStyle5.Format = "D";
			dataGridViewCellStyle5.NullValue = null;
			this.CreateDate.DefaultCellStyle = dataGridViewCellStyle5;
			this.CreateDate.HeaderText = "Ngày";
			this.CreateDate.MinimumWidth = 89;
			this.CreateDate.Name = "CreateDate";
			this.CreateDate.Width = 89;
			this._Name.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this._Name.DataPropertyName = "_Name";
			this._Name.HeaderText = "Thông tin bệnh nhân";
			this._Name.MinimumWidth = 200;
			this._Name.Name = "_Name";
			this._Name.Width = 200;
			this.DoctorName.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.DoctorName.DataPropertyName = "_DoctorName";
			this.DoctorName.HeaderText = "DoctorName";
			this.DoctorName.MinimumWidth = 203;
			this.DoctorName.Name = "DoctorName";
			this.DoctorName.Width = 203;
			this.DoctorDesease.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.DoctorDesease.DataPropertyName = "_DoctorDesease";
			this.DoctorDesease.HeaderText = "DoctorDesease";
			this.DoctorDesease.MinimumWidth = 183;
			this.DoctorDesease.Name = "DoctorDesease";
			this.DoctorDesease.Width = 183;
			this.ProductName.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.ProductName.DataPropertyName = "ProductName";
			this.ProductName.HeaderText = "ProductName";
			this.ProductName.MinimumWidth = 165;
			this.ProductName.Name = "ProductName";
			this.ProductName.Width = 165;
			this.ProductNumber.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.ProductNumber.DataPropertyName = "ProductNumber";
			dataGridViewCellStyle6.Alignment = DataGridViewContentAlignment.MiddleRight;
			this.ProductNumber.DefaultCellStyle = dataGridViewCellStyle6;
			this.ProductNumber.HeaderText = "N";
			this.ProductNumber.MinimumWidth = 46;
			this.ProductNumber.Name = "ProductNumber";
			this.ProductNumber.Width = 46;
			this.Column1.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.Column1.HeaderText = "Column1";
			this.Column1.Name = "Column1";
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			base.ClientSize = new Size(900, 600);
			base.Controls.Add(this.btnSearch);
			base.Controls.Add(this.label25);
			base.Controls.Add(this.label17);
			base.Controls.Add(this.dtpTo);
			base.Controls.Add(this.dtpFrom);
			base.Controls.Add(this.btnExportToExcel);
			base.Controls.Add(this.btnPrint);
			base.Controls.Add(this.btnClose);
			base.Controls.Add(this.dgvBill);
			base.Controls.Add(this.label8);
			base.Controls.Add(this.label7);
			base.Controls.Add(this.label6);
			base.Controls.Add(this.label5);
			base.Controls.Add(this.label4);
			base.Controls.Add(this.label3);
			base.Controls.Add(this.label2);
			base.Controls.Add(this.label1);
			this.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			//base.Icon = (System.Drawing.Icon)componentResourceManager.GetObject("$this.Icon");
			base.KeyPreview = true;
			base.Name = "frmTracePatients";
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "SỔ THEO DÕI BỆNH NHÂN";
			base.Load += new EventHandler(this.frmTracePatients_Load);
			base.KeyDown += new KeyEventHandler(this.frmTracePatients_KeyDown);
			((ISupportInitialize)this.dgvBill).EndInit();
			base.ResumeLayout(false);
			base.PerformLayout();
		}
		public frmTracePatients()
		{
			this.InitializeComponent();
		}
		private void frmTracePatients_Load(object sender, EventArgs e)
		{
			this.currWhID = this.objFunc.getWarehouse(this.userName);
			this.getBill();
		}
		private void getBill()
		{
			this.objTable = new DataTable();
			DataColumn column = new DataColumn("CreateDate", typeof(DateTime));
			DataColumn column2 = new DataColumn("_Name", typeof(string));
			DataColumn column3 = new DataColumn("_DoctorName", typeof(string));
			DataColumn column4 = new DataColumn("_DoctorDesease", typeof(string));
			DataColumn column5 = new DataColumn("ProductName", typeof(string));
			DataColumn column6 = new DataColumn("ProductNumber", typeof(string));
			this.objTable.Columns.Add(column);
			this.objTable.Columns.Add(column2);
			this.objTable.Columns.Add(column3);
			this.objTable.Columns.Add(column4);
			this.objTable.Columns.Add(column5);
			this.objTable.Columns.Add(column6);
			this.dgvBill.AutoGenerateColumns = false;
			SqlConnection sqlConnection = new SqlConnection(this.objFunc.strConnectionString);
			sqlConnection.Open();
			string cmdText = "SELECT * FROM [TabBill] WHERE [TabBill].[CreateDate] BETWEEN @ObjDate1 AND @objDate2 AND [_DoctorName] <> 'NONE' AND TypeInput = 'OUT4' AND [WID] = '" + this.currWhID + "' ORDER BY [TabBill].[CreateDate] ASC";
			SqlCommand sqlCommand = new SqlCommand(cmdText, sqlConnection);
			SqlParameter sqlParameter = new SqlParameter("ObjDate1", SqlDbType.DateTime);
			SqlParameter sqlParameter2 = new SqlParameter("ObjDate2", SqlDbType.DateTime);
			sqlParameter.Value = DateTime.Parse(this.dtpFrom.Value.ToString().Substring(0, 10) + " 00:00:00 AM");
			sqlParameter2.Value = DateTime.Parse(this.dtpTo.Value.ToString().Substring(0, 10) + " 11:59:59 PM");
			sqlCommand.Parameters.Add(sqlParameter);
			sqlCommand.Parameters.Add(sqlParameter2);
			SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
			while (sqlDataReader.Read())
			{
				this.getBillDetail(sqlDataReader["ID"].ToString(), DateTime.Parse(sqlDataReader["CreateDate"].ToString()), sqlDataReader["_Name"].ToString(), sqlDataReader["_DoctorName"].ToString(), sqlDataReader["_DoctorDesease"].ToString(), this.objTable);
			}
			sqlDataReader.Close();
			this.dgvBill.DataSource = this.objTable;
			sqlConnection.Close();
			sqlConnection.Dispose();
		}
		private void getBillDetail(string billID, DateTime CreateDate, string _Name, string _DoctorName, string _DoctorDoctorDesease, DataTable objTable)
		{
			SqlConnection sqlConnection = new SqlConnection(this.objFunc.strConnectionString);
			sqlConnection.Open();
			string cmdText = "SELECT [productName],[productNumber] FROM [TabDetailBill] WHERE [billID] = '" + billID + "'";
			SqlCommand sqlCommand = new SqlCommand(cmdText, sqlConnection);
			int num = 0;
			SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
			while (sqlDataReader.Read())
			{
				if (num == 0)
				{
					objTable.Rows.Add(new object[]
					{
						CreateDate,
						_Name,
						_DoctorName,
						_DoctorDoctorDesease,
						sqlDataReader["productName"].ToString(),
						sqlDataReader["productNumber"].ToString()
					});
				}
				else
				{
					objTable.Rows.Add(new object[]
					{
						null,
						"",
						"",
						"",
						sqlDataReader["productName"].ToString(),
						sqlDataReader["productNumber"].ToString()
					});
				}
				num++;
			}
			sqlDataReader.Close();
			this.dgvBill.DataSource = this.objTable;
			sqlConnection.Close();
			sqlConnection.Dispose();
		}
		private void btnClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void frmTracePatients_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				base.Close();
			}
			else
			{
				if (e.KeyCode == Keys.F7)
				{
					this.btnPrint.PerformClick();
				}
			}
		}
		private void btnPrint_Click(object sender, EventArgs e)
		{
			frmTracePatientsView frmTracePatientsView = new frmTracePatientsView();
			frmTracePatientsPrint.objTable = this.objTable;
			frmTracePatientsView.ShowDialog();
		}
		private void btnExportToExcel_Click(object sender, EventArgs e)
		{
			try
			{
				frmTracePatientsPrint.objTable = new DataTable();
				frmTracePatientsPrint.objTable = this.objTable;
				ActiveReport3 activeReport = new frmTracePatientsPrint();
				activeReport.Run();
				XlsExport xlsExport = new XlsExport();
				SaveFileDialog saveFileDialog = new SaveFileDialog();
				saveFileDialog.ShowDialog();
				string text = saveFileDialog.FileName;
				if (text != "")
				{
					if (!text.ToUpper().Contains(".XLS"))
					{
						text += ".xls";
					}
					xlsExport.MinRowHeight = 0f;
					xlsExport.UseCellMerging = true;
					xlsExport.Export(activeReport.Document, text);
					MessageBox.Show("Hệ thống đã hoàn thành việc xuất dữ liệu ra file Excel", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				}
				else
				{
					MessageBox.Show("Bạn chưa chọn đường dẫn và tên file cần xuất!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				}
			}
			catch
			{
			}
		}
		private void btnSearch_Click(object sender, EventArgs e)
		{
			this.getBill();
		}
	}
}
